package com.bdqn.zhang.servlet;

import cn.dev33.satoken.stp.StpUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(urlPatterns = {"/login"})
public class LoginServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        String username = req.getParameter("username");
//        if (username != null){
//            StpUtil.setLoginId(username);
//        }
//        if (StpUtil.isLogin()){
//            System.out.println("123");
//        }
        req.getRequestDispatcher("/WEB-INF/index.jsp").forward(req,resp);
    }
}
